<%@include file="../../generic/inc/head.jsp"%>

<%@ page import="fr.mywiki.view.web.struts.form.admin.account.EditAccountForm" %>
<%@ page import="fr.mywiki.model.valueobjects.Profile"%>

<script>
<!--
	function cancel() {
		document.forms["editAccountForm"].method.value="cancel";
		document.forms["editAccountForm"].submit();
	}
-->
</script>

<div id="mainPanel">
	<h1>
		<logic:equal value="<%=EditAccountForm.TYPE_CREATION%>" property="type" name="editAccountForm">
			<bean:message key="admin.user.creation"/>
		</logic:equal>
		<logic:equal value="<%=EditAccountForm.TYPE_EDITION%>" property="type" name="editAccountForm">
			<bean:message key="admin.user.edition"/>
		</logic:equal>
	</h1>
	<p class="error">
		<html:errors bundle="ERROR_RESSOURCE_KEY"/>
	</p>
	<html:form action="editAccount">

<%
		String clientName = "editAccount.do";
		String formName = "editAccountForm";
		String modifDiv = "structName";
%>
		<div id="mainLayer">
	
			<html:hidden property="method" value="validate"/>
	
			<bean:message key="user.login"/>:&nbsp;<html:text name="editAccountForm" property="login"/>
			<br/>
			
			<logic:equal value="true" property="displayPassword" name="editAccountForm">
				<bean:message key="user.password"/>:&nbsp;<html:password name="editAccountForm" property="password"/>
				<br/>
				<bean:message key="admin.user.password2"/>:&nbsp;<html:password name="editAccountForm" property="password2"/>
				<br/>
			</logic:equal>
			
			<bean:message key="user.profile"/>:&nbsp;
			<html:select property="profileId" size="1">
<%
			EditAccountForm form = (EditAccountForm) session.getAttribute(formName);
			Iterator itProf = form.getProfiles().iterator();
			while(itProf.hasNext()) {
				Profile profile = (Profile) itProf.next();
				String selected="";
				if(profile.getId().equals(form.getProfileId()))
					selected="selected";
%>
				<option value="<%=profile.getId()%>" <%=selected%> >
					<%=profile.getName()%>
				</option>
<%
			}
%>
			</html:select>
			<br/>
	
			<%@include file="../../generic/tree/treeModalPopup.jsp"%>
	
			<bean:message key="user.structure"/> : 
			<a href="javascript:openStructurePopup();">
			<span id="structName">
				<bean:write name="editAccountForm" property="structName"/>
			</span>
			</a>
			<br/>
	
			<a href="#" onclick="javascript:submit();">
				<bean:message key="action.validate"/>
			</a>&nbsp;
			<a href="#" onclick="javascript:cancel();">
				<bean:message key="action.cancel"/>
			</a>
		</div>
	</html:form>
</div>

<%@include file="../../generic/inc/foot.jsp"%>